
<#include "/shared/style.ftl" />
<#include "/shared/javascript.ftl" />

<fieldset class="layui-elem-field layui-field-title" style="width: 45%;">
    <legend>修改角色</legend>
    <form class="layui-form" action="${baseUrlAdmin}/role/edit" method="post">
        <input type="hidden" name="id" value="${role.id}" />
        <div class="layui-form-item">
            <label class="layui-form-label">名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" required  lay-verify="required" placeholder="请输入名称" autocomplete="off" class="layui-input" value="${role.name}" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">等级</label>
            <div class="layui-input-block">
                <input type="number" name="grade" required  lay-verify="required" placeholder="请输入等级" autocomplete="off" class="layui-input" value="${role.grade}" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="number" name="sort" required  lay-verify="required" placeholder="请输入排序" autocomplete="off" class="layui-input" value="${role.sort}" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea class="layui-textarea" name="remark" placeholder="请输入备注">${role.remark}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <select name="status" lay-verify="required">
                <#list statuses as status>
                    <option value="${status.value}">${status.text}</option>
                </#list>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formSubmit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</fieldset>

<script type="text/javascript">
    var message = '${message}';
    if (message !== '') {
        parent.layuiLayer.confirm(message, function (index) {
            layuiManager.parentCloseTab(layuiTabConfig.roleEdit.id);
            parent.layuiLayer.close(index);
        });
    }

    $('select[name="status"]').val('${role.status}');
    layui.use(['form'], function () {
        var form = layui.form, layer = layui.layer;
        //监听提交
        form.on('submit(formSubmit)', function (data) {
            layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            });
            return false;
        });
    });
</script>
